package com.prs.crm.action.oa.flow;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.oa.Apply;
import com.prs.crm.service.oa.ApplyService;

public class ApplyFlowAction extends FlowAction<Apply>{
	private ApplyService applyService;
	private Apply apply;
	private PaginationSupport pagination;
	
	@Action("listApplyFlow")
	public String listApplyFlow() {
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getApplyService().listFlowTask(Apply.class, pagination, AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@Action("editApplyFlow")
	public String editApplyFlow() {
		this.displayEndNodes();		
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="submitApplyFlow",results={@Result(name="success",type="redirect",location="listApplyFlow")})
	public String submitApplyFlow() {
		this.getApplyService().execute(this.getNode(), this.getDetail(), apply, AppContext.getAccountContext().currentUser());
		this.setPrompt("提交成功");
		return SUCCESS;
	}
	
	public ApplyService getApplyService() {
		return applyService;
	}
	public void setApplyService(ApplyService applyService) {
		this.applyService = applyService;
	}
	public Apply getApply() {
		return apply;
	}
	public void setApply(Apply apply) {
		this.apply = apply;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	
}
